unit Class_QBD_FL;

interface
uses
  Classes,SysUtils,Uni,UniEngine;

type
  TQBDFL=class(TUniEngine)
  private
    FJFBKDID      : string;
    FJFBKDFLID    : Integer;
    FJFBKDDWBML   : string;
    FJFBKDYBTAG   : Integer;
    FJFBKDFLKMBML : string;
    FJFBKDFLXMBML : string;
    FJFBKDFLZJXZ  : string;
    FJFBKDFLZCLX  : string;
    FJFBKDFLSNJY  : Extended;
    FJFBKDFLNCYS  : Extended;
    FJFBKDFLZJJE  : Extended;
    FJFBKDFLTZS   : Extended;
    FJFBKDFLYBS   : Extended;
    FJFBKDFLSQS   : Extended;
    FJFBKDFLHDS   : Extended;
    FJFBKDFLYSJY  : Extended;
    FJFBKDFLZY    : string;
    FJFBKDFLWBHDJE: Extended;
    FJFBKDFLBKCS  : Integer;
    FFUNDSKIND    : string;
    FJFBKDFLSXBZ  : Integer;
  private
    FRowIndex     : Integer;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
    function  EXPSQL:string;
    function  ExpSQL_IN_ZBDFL:string;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property JFBKDID      : string read FJFBKDID       write FJFBKDID;
    property JFBKDFLID    : Integer read FJFBKDFLID     write FJFBKDFLID;
    property JFBKDDWBML   : string read FJFBKDDWBML    write FJFBKDDWBML;
    property JFBKDYBTAG   : Integer read FJFBKDYBTAG    write FJFBKDYBTAG;
    property JFBKDFLKMBML : string read FJFBKDFLKMBML  write FJFBKDFLKMBML;
    property JFBKDFLXMBML : string read FJFBKDFLXMBML  write FJFBKDFLXMBML;
    property JFBKDFLZJXZ  : string read FJFBKDFLZJXZ   write FJFBKDFLZJXZ;
    property JFBKDFLZCLX  : string read FJFBKDFLZCLX   write FJFBKDFLZCLX;
    property JFBKDFLSNJY  : Extended read FJFBKDFLSNJY   write FJFBKDFLSNJY;
    property JFBKDFLNCYS  : Extended read FJFBKDFLNCYS   write FJFBKDFLNCYS;
    property JFBKDFLZJJE  : Extended read FJFBKDFLZJJE   write FJFBKDFLZJJE;
    property JFBKDFLTZS   : Extended read FJFBKDFLTZS    write FJFBKDFLTZS;
    property JFBKDFLYBS   : Extended read FJFBKDFLYBS    write FJFBKDFLYBS;
    property JFBKDFLSQS   : Extended read FJFBKDFLSQS    write FJFBKDFLSQS;
    property JFBKDFLHDS   : Extended read FJFBKDFLHDS    write FJFBKDFLHDS;
    property JFBKDFLYSJY  : Extended read FJFBKDFLYSJY   write FJFBKDFLYSJY;
    property JFBKDFLZY    : string read FJFBKDFLZY     write FJFBKDFLZY;
    property JFBKDFLWBHDJE: Extended read FJFBKDFLWBHDJE write FJFBKDFLWBHDJE;
    property JFBKDFLBKCS  : Integer read FJFBKDFLBKCS   write FJFBKDFLBKCS;
    property FUNDSKIND    : string read FFUNDSKIND     write FFUNDSKIND;
    property JFBKDFLSXBZ  : Integer read FJFBKDFLSXBZ   write FJFBKDFLSXBZ;
    property RowIndex     : Integer read FRowIndex      write FRowIndex;
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AJFBKDFL:TQBDFL):TQBDFL;overload;        
    class procedure CopyIt(AJFBKDFL:TQBDFL;var Result:TQBDFL);overload;
  end;

implementation

{ TQBDFL }
procedure TQBDFL.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('JFBKD_ID').Value := JFBKDID;
        ParamByName('JFBKD_FL_ID').Value := JFBKDFLID;
        ParamByName('JFBKD_DWBML').Value := JFBKDDWBML;
        ParamByName('JFBKD_YBTAG').Value := JFBKDYBTAG;
        ParamByName('JFBKD_FL_KMBML').Value := JFBKDFLKMBML;
        ParamByName('JFBKD_FL_XMBML').Value := JFBKDFLXMBML;
        ParamByName('JFBKD_FL_ZJXZ').Value := JFBKDFLZJXZ;
        ParamByName('JFBKD_FL_ZCLX').Value := JFBKDFLZCLX;
        ParamByName('JFBKD_FL_SNJY').Value := JFBKDFLSNJY;
        ParamByName('JFBKD_FL_NCYS').Value := JFBKDFLNCYS;
        ParamByName('JFBKD_FL_ZJJE').Value := JFBKDFLZJJE;
        ParamByName('JFBKD_FL_TZS').Value := JFBKDFLTZS;
        ParamByName('JFBKD_FL_YBS').Value := JFBKDFLYBS;
        ParamByName('JFBKD_FL_SQS').Value := JFBKDFLSQS;
        ParamByName('JFBKD_FL_HDS').Value := JFBKDFLHDS;
        ParamByName('JFBKD_FL_YSJY').Value := JFBKDFLYSJY;
        ParamByName('JFBKD_FL_ZY').Value := JFBKDFLZY;
        ParamByName('JFBKD_FL_WBHDJE').Value := JFBKDFLWBHDJE;
        ParamByName('JFBKD_FL_BKCS').Value := JFBKDFLBKCS;
        ParamByName('FUNDSKIND').Value := FUNDSKIND;
        ParamByName('JFBKD_FL_SXBZ').Value := JFBKDFLSXBZ; 
      end;
      otEdit:
      begin
        ParamByName('JFBKD_ID').Value := JFBKDID;
        ParamByName('JFBKD_FL_ID').Value := JFBKDFLID;
        ParamByName('JFBKD_DWBML').Value := JFBKDDWBML;
        ParamByName('JFBKD_YBTAG').Value := JFBKDYBTAG;
        ParamByName('JFBKD_FL_KMBML').Value := JFBKDFLKMBML;
        ParamByName('JFBKD_FL_XMBML').Value := JFBKDFLXMBML;
        ParamByName('JFBKD_FL_ZJXZ').Value := JFBKDFLZJXZ;
        ParamByName('JFBKD_FL_ZCLX').Value := JFBKDFLZCLX;
        ParamByName('JFBKD_FL_SNJY').Value := JFBKDFLSNJY;
        ParamByName('JFBKD_FL_NCYS').Value := JFBKDFLNCYS;
        ParamByName('JFBKD_FL_ZJJE').Value := JFBKDFLZJJE;
        ParamByName('JFBKD_FL_TZS').Value := JFBKDFLTZS;
        ParamByName('JFBKD_FL_YBS').Value := JFBKDFLYBS;
        ParamByName('JFBKD_FL_SQS').Value := JFBKDFLSQS;
        ParamByName('JFBKD_FL_HDS').Value := JFBKDFLHDS;
        ParamByName('JFBKD_FL_YSJY').Value := JFBKDFLYSJY;
        ParamByName('JFBKD_FL_ZY').Value := JFBKDFLZY;
        ParamByName('JFBKD_FL_WBHDJE').Value := JFBKDFLWBHDJE;
        ParamByName('JFBKD_FL_BKCS').Value := JFBKDFLBKCS;
        ParamByName('FUNDSKIND').Value := FUNDSKIND;
        ParamByName('JFBKD_FL_SXBZ').Value := JFBKDFLSXBZ; 
      end;  
      otDelt:
      begin
        ParamByName('JFBKD_ID').Value := JFBKDID;
        ParamByName('JFBKD_FL_ID').Value := JFBKDFLID;
        ParamByName('JFBKD_DWBML').Value := JFBKDDWBML;
        ParamByName('JFBKD_YBTAG').Value := JFBKDYBTAG;
 
      end;  
    end;
  end;
end;

function TQBDFL.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('TBL_JFBKD_FL',['JFBKD_ID',JFBKDID,'JFBKD_FL_ID',JFBKDFLID,'JFBKD_DWBML',JFBKDDWBML,'JFBKD_YBTAG',JFBKDYBTAG],AUniConnection);
end;

function TQBDFL.GetNextIdex: Integer;
begin

end;

function TQBDFL.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TQBDFL.GetStrDelete: string;
begin
  Result:='DELETE FROM TBL_JFBKD_FL WHERE   JFBKD_ID=:JFBKD_ID AND JFBKD_FL_ID=:JFBKD_FL_ID AND JFBKD_DWBML=:JFBKD_DWBML AND JFBKD_YBTAG=:JFBKD_YBTAG';
end;

function TQBDFL.GetStrInsert: string;
begin
  Result:='INSERT INTO TBL_JFBKD_FL'
         +'    ( JFBKD_ID, JFBKD_FL_ID, JFBKD_DWBML, JFBKD_YBTAG, JFBKD_FL_KMBML'
         +'    , JFBKD_FL_XMBML, JFBKD_FL_ZJXZ, JFBKD_FL_ZCLX, JFBKD_FL_SNJY'
         +'    , JFBKD_FL_NCYS, JFBKD_FL_ZJJE, JFBKD_FL_TZS, JFBKD_FL_YBS'
         +'    , JFBKD_FL_SQS, JFBKD_FL_HDS, JFBKD_FL_YSJY, JFBKD_FL_ZY'
         +'    , JFBKD_FL_WBHDJE, JFBKD_FL_BKCS, FUNDSKIND, JFBKD_FL_SXBZ)'
         +'    VALUES'
         +'    (:JFBKD_ID,:JFBKD_FL_ID,:JFBKD_DWBML,:JFBKD_YBTAG,:JFBKD_FL_KMBML'
         +'    ,:JFBKD_FL_XMBML,:JFBKD_FL_ZJXZ,:JFBKD_FL_ZCLX,:JFBKD_FL_SNJY'
         +'    ,:JFBKD_FL_NCYS,:JFBKD_FL_ZJJE,:JFBKD_FL_TZS,:JFBKD_FL_YBS'
         +'    ,:JFBKD_FL_SQS,:JFBKD_FL_HDS,:JFBKD_FL_YSJY,:JFBKD_FL_ZY'
         +'    ,:JFBKD_FL_WBHDJE,:JFBKD_FL_BKCS,:FUNDSKIND,:JFBKD_FL_SXBZ)';
end;

function TQBDFL.GetStrsIndex: string;
begin
  Result:=Format('%S-%D-%S-%D',[JFBKDID,JFBKDFLID,JFBKDDWBML,JFBKDYBTAG]);
end;

function TQBDFL.GetStrUpdate: string;
begin
  Result:='UPDATE  TBL_JFBKD_FL SET'
         +'    JFBKD_FL_KMBML=:JFBKD_FL_KMBML,'
         +'    JFBKD_FL_XMBML=:JFBKD_FL_XMBML,'
         +'    JFBKD_FL_ZJXZ=:JFBKD_FL_ZJXZ,'
         +'    JFBKD_FL_ZCLX=:JFBKD_FL_ZCLX,'
         +'    JFBKD_FL_SNJY=:JFBKD_FL_SNJY,'
         +'    JFBKD_FL_NCYS=:JFBKD_FL_NCYS,'
         +'    JFBKD_FL_ZJJE=:JFBKD_FL_ZJJE,'
         +'    JFBKD_FL_TZS=:JFBKD_FL_TZS,'
         +'    JFBKD_FL_YBS=:JFBKD_FL_YBS,'
         +'    JFBKD_FL_SQS=:JFBKD_FL_SQS,'
         +'    JFBKD_FL_HDS=:JFBKD_FL_HDS,'
         +'    JFBKD_FL_YSJY=:JFBKD_FL_YSJY,'
         +'    JFBKD_FL_ZY=:JFBKD_FL_ZY,'
         +'    JFBKD_FL_WBHDJE=:JFBKD_FL_WBHDJE,'
         +'    JFBKD_FL_BKCS=:JFBKD_FL_BKCS,'
         +'    FUNDSKIND=:FUNDSKIND,'
         +'    JFBKD_FL_SXBZ=:JFBKD_FL_SXBZ'
         +'    WHERE JFBKD_ID=:JFBKD_ID'
         +'    AND   JFBKD_FL_ID=:JFBKD_FL_ID'
         +'    AND   JFBKD_DWBML=:JFBKD_DWBML'
         +'    AND   JFBKD_YBTAG=:JFBKD_YBTAG';
end;

constructor TQBDFL.Create;
begin

end;

destructor TQBDFL.Destroy;
begin

  inherited;
end;

class function TQBDFL.ReadDS(AUniQuery: TUniQuery): TUniEngine;
begin
  Result:=TQBDFL.Create;
  with TQBDFL(Result) do
  begin
    JFBKDID      :=AUniQuery.FieldByName('JFBKD_ID').AsString;
    JFBKDFLID    :=AUniQuery.FieldByName('JFBKD_FL_ID').AsInteger;
    JFBKDDWBML   :=AUniQuery.FieldByName('JFBKD_DWBML').AsString;
    JFBKDYBTAG   :=AUniQuery.FieldByName('JFBKD_YBTAG').AsInteger;
    JFBKDFLKMBML :=AUniQuery.FieldByName('JFBKD_FL_KMBML').AsString;
    JFBKDFLXMBML :=AUniQuery.FieldByName('JFBKD_FL_XMBML').AsString;
    JFBKDFLZJXZ  :=AUniQuery.FieldByName('JFBKD_FL_ZJXZ').AsString;
    JFBKDFLZCLX  :=AUniQuery.FieldByName('JFBKD_FL_ZCLX').AsString;
    JFBKDFLSNJY  :=AUniQuery.FieldByName('JFBKD_FL_SNJY').AsFloat;
    JFBKDFLNCYS  :=AUniQuery.FieldByName('JFBKD_FL_NCYS').AsFloat;
    JFBKDFLZJJE  :=AUniQuery.FieldByName('JFBKD_FL_ZJJE').AsFloat;
    JFBKDFLTZS   :=AUniQuery.FieldByName('JFBKD_FL_TZS').AsFloat;
    JFBKDFLYBS   :=AUniQuery.FieldByName('JFBKD_FL_YBS').AsFloat;
    JFBKDFLSQS   :=AUniQuery.FieldByName('JFBKD_FL_SQS').AsFloat;
    JFBKDFLHDS   :=AUniQuery.FieldByName('JFBKD_FL_HDS').AsFloat;
    JFBKDFLYSJY  :=AUniQuery.FieldByName('JFBKD_FL_YSJY').AsFloat;
    JFBKDFLZY    :=AUniQuery.FieldByName('JFBKD_FL_ZY').AsString;
    JFBKDFLWBHDJE:=AUniQuery.FieldByName('JFBKD_FL_WBHDJE').AsFloat;
    JFBKDFLBKCS  :=AUniQuery.FieldByName('JFBKD_FL_BKCS').AsInteger;
    FUNDSKIND    :=AUniQuery.FieldByName('FUNDSKIND').AsString;
    JFBKDFLSXBZ  :=AUniQuery.FieldByName('JFBKD_FL_SXBZ').AsInteger;
  end;  
end;

class procedure TQBDFL.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
begin
  if Result=nil then Exit;
  with TQBDFL(Result) do
  begin
    JFBKDID      :=AUniQuery.FieldByName('JFBKD_ID').AsString;
    JFBKDFLID    :=AUniQuery.FieldByName('JFBKD_FL_ID').AsInteger;
    JFBKDDWBML   :=AUniQuery.FieldByName('JFBKD_DWBML').AsString;
    JFBKDYBTAG   :=AUniQuery.FieldByName('JFBKD_YBTAG').AsInteger;
    JFBKDFLKMBML :=AUniQuery.FieldByName('JFBKD_FL_KMBML').AsString;
    JFBKDFLXMBML :=AUniQuery.FieldByName('JFBKD_FL_XMBML').AsString;
    JFBKDFLZJXZ  :=AUniQuery.FieldByName('JFBKD_FL_ZJXZ').AsString;
    JFBKDFLZCLX  :=AUniQuery.FieldByName('JFBKD_FL_ZCLX').AsString;
    JFBKDFLSNJY  :=AUniQuery.FieldByName('JFBKD_FL_SNJY').AsFloat;
    JFBKDFLNCYS  :=AUniQuery.FieldByName('JFBKD_FL_NCYS').AsFloat;
    JFBKDFLZJJE  :=AUniQuery.FieldByName('JFBKD_FL_ZJJE').AsFloat;
    JFBKDFLTZS   :=AUniQuery.FieldByName('JFBKD_FL_TZS').AsFloat;
    JFBKDFLYBS   :=AUniQuery.FieldByName('JFBKD_FL_YBS').AsFloat;
    JFBKDFLSQS   :=AUniQuery.FieldByName('JFBKD_FL_SQS').AsFloat;
    JFBKDFLHDS   :=AUniQuery.FieldByName('JFBKD_FL_HDS').AsFloat;
    JFBKDFLYSJY  :=AUniQuery.FieldByName('JFBKD_FL_YSJY').AsFloat;
    JFBKDFLZY    :=AUniQuery.FieldByName('JFBKD_FL_ZY').AsString;
    JFBKDFLWBHDJE:=AUniQuery.FieldByName('JFBKD_FL_WBHDJE').AsFloat;
    JFBKDFLBKCS  :=AUniQuery.FieldByName('JFBKD_FL_BKCS').AsInteger;
    FUNDSKIND    :=AUniQuery.FieldByName('FUNDSKIND').AsString;
    JFBKDFLSXBZ  :=AUniQuery.FieldByName('JFBKD_FL_SXBZ').AsInteger;
  end;  
end;

class function  TQBDFL.CopyIt(AJFBKDFL: TQBDFL): TQBDFL;
begin
  Result:=TQBDFL.Create;
  TQBDFL.CopyIt(AJFBKDFL,Result)
end;

class procedure TQBDFL.CopyIt(AJFBKDFL:TQBDFL;var Result:TQBDFL);
begin
  if Result=nil then Exit;
  Result.JFBKDID      :=AJFBKDFL.JFBKDID;
  Result.JFBKDFLID    :=AJFBKDFL.JFBKDFLID;
  Result.JFBKDDWBML   :=AJFBKDFL.JFBKDDWBML;
  Result.JFBKDYBTAG   :=AJFBKDFL.JFBKDYBTAG;
  Result.JFBKDFLKMBML :=AJFBKDFL.JFBKDFLKMBML;
  Result.JFBKDFLXMBML :=AJFBKDFL.JFBKDFLXMBML;
  Result.JFBKDFLZJXZ  :=AJFBKDFL.JFBKDFLZJXZ;
  Result.JFBKDFLZCLX  :=AJFBKDFL.JFBKDFLZCLX;
  Result.JFBKDFLSNJY  :=AJFBKDFL.JFBKDFLSNJY;
  Result.JFBKDFLNCYS  :=AJFBKDFL.JFBKDFLNCYS;
  Result.JFBKDFLZJJE  :=AJFBKDFL.JFBKDFLZJJE;
  Result.JFBKDFLTZS   :=AJFBKDFL.JFBKDFLTZS;
  Result.JFBKDFLYBS   :=AJFBKDFL.JFBKDFLYBS;
  Result.JFBKDFLSQS   :=AJFBKDFL.JFBKDFLSQS;
  Result.JFBKDFLHDS   :=AJFBKDFL.JFBKDFLHDS;
  Result.JFBKDFLYSJY  :=AJFBKDFL.JFBKDFLYSJY;
  Result.JFBKDFLZY    :=AJFBKDFL.JFBKDFLZY;
  Result.JFBKDFLWBHDJE:=AJFBKDFL.JFBKDFLWBHDJE;
  Result.JFBKDFLBKCS  :=AJFBKDFL.JFBKDFLBKCS;
  Result.FUNDSKIND    :=AJFBKDFL.FUNDSKIND;
  Result.JFBKDFLSXBZ  :=AJFBKDFL.JFBKDFLSXBZ;
end;

function TQBDFL.EXPSQL: string;
begin
  Result:='SELECT COUNT(ZBD_FL_BH) FROM TBL_ZBD_FL WHERE 1=1  AND  ZBD_FL_ZJLX=%S AND ZBD_FL_ZCLX=%S AND ZBD_FL_BJKM=%S AND ZBD_DWBML=%S';
  Result:=Format(Result,[QuotedStr(JFBKDFLZJXZ),QuotedStr(JFBKDFLZCLX),QuotedStr(JFBKDFLKMBML),QuotedStr(JFBKDDWBML)]);

  if JFBKDFLZCLX='002' then
  begin
    Result:=Result +'    AND  ZBD_FL_XJKM=%S';
    Result:=Format(Result,[QuotedStr(JFBKDFLXMBML)]);
  end;
end;

function TQBDFL.ExpSQL_IN_ZBDFL: string;
begin
  Result:='SELECT * FROM TBL_ZBD_FL WHERE 1=1  AND  ZBD_FL_ZJLX=%S AND ZBD_FL_ZCLX=%S AND ZBD_FL_BJKM=%S  AND ZBD_DWBML=%S';
  Result:=Format(Result,[QuotedStr(JFBKDFLZJXZ),QuotedStr(JFBKDFLZCLX),QuotedStr(JFBKDFLKMBML),QuotedStr(JFBKDDWBML)]);

  if JFBKDFLZCLX='002' then
  begin
    Result:=Result +'    AND  ZBD_FL_XJKM=%S';
    Result:=Format(Result,[QuotedStr(JFBKDFLXMBML)]);
  end else
  if JFBKDFLZCLX='001' then 
  begin
    Result:=Result +'    AND  ZBD_FL_XJKM=%S';
    Result:=Format(Result,[QuotedStr(JFBKDFLXMBML)]);
  end;
end;

end.

